{include file="public/_header"}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
<!--            <div class="layui-form-item">-->
<!--                <div class="layui-inline">&emsp;-->
<!--                    <button id="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;-->
<!--                </div>-->
<!--            </div>-->
            <table id="tableContainer" lay-filter="tableContainer"></table>
        </div>
    </div>
</div>
<input type="hidden" name="pcode" id="pcode" value="{$pcode}">
{include file="public/_footer"}
<script>
    layui.use(['layer', 'form', 'admin', 'table', 'util','xmSelect'],function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var table = layui.table;

        initTable();
        function initTable() {
            var pcode = $('#pcode').val();
            var url = "{:url('getData')}?pcode=" + pcode;
            var insTb = table.render({
                elem: '#tableContainer',
                url: url,
                // toolbar: ['<p>',
                //     '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                //     '</p>'].join(''),
                cellMinWidth: 100,
                cols : [[
                    {field: 'code', title: '行政编码'},
                    {field: 'name', title: '名称'},
                    {title: '操作', toolbar: '#barDemo', align: 'center', width: 200, minWidth: 200}
                ]]
            });
        }
        table.on('tool(tableContainer)', function (obj) {
            if (obj.event === 'level') { // 修改
                window.location.href = 'index.html?pcode=' + obj.data.code;
            }
        });
    });
</script>
<script type="text/html" id="barDemo">
    {{#  if (d.level < 5) { }}
        <a class="layui-btn layui-btn-xs" lay-event="level">查看下级</a>
    {{#  } }}

</script>
</body>
</html>